import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import layout from '@/views/layout'
import Home from '@/views/Home'
//点击跳转同一个路径
//在vueRouter上配置路由跳转，在router中的index.js中加上一下代码
const routerRush=VueRouter.prototype.push;
VueRouter.prototype.push=function(location){
  return routerPush.call(this.location).catch(err=>{})

}

//导入商品管理
const Goods=()=>import('../views/GoodsManger/index.vue')
const GoodsList=()=>import('../views/GoodsManger/List/index.vue')
const GoodsCategory=()=>import('../views/GoodsManger/Category/index.vue')

//导入订单管理
const OrderManger=()=>import('../views/OrderManger/index.vue')
const OrderList=()=>import('../views/OrderManger/List')
const OrderCollect=()=>import('../views/OrderManger/Collect')
const OrderAdting=()=>import('../views/OrderManger/Aditing')

//导入广告分类
const Adert=()=>import('../views/Adert')
const AdertList=()=>import('../views/Adert/List')
const AdertManger=()=>import('../views/Adert/Manger')

//数据统计
const Data=()=>import('../views/Data')


const routes = [
  {
    path:'/',
    component:layout,
    children:[
      {
        path:'/',
        name:'home',
        component:Home
      },
      //商品管理
      {
        path:'/goods',
        name:'Goods',
        component:Goods,
        redirect:'/goods/list',
        //三级路由
        children:[
          {
            path:'list',
            name:'GoodsList',
            component:GoodsList
          },
          {
            path:'category',
            name:'GoodsCategory',
            component:GoodsCategory
          }
        ]

      },
      //订单管理
      {
        path:'/order',
        name:'OrderManger',
        component:OrderManger,
        redirect:'/order/list',
        //三级路由
        children:[
          {
            path:'list',
            name:'OrderList',
            component:OrderList
          },
          
          {
            path:'collect',
            name:'OrderCollect',
            component:OrderCollect
          },
          {
            path:'addting',
            name:'OrderAdting',
            component:OrderAdting
          }
          
        ]

      },
      //广告分类
      {
        path:'/adert',
        name:'Adert',
        component:Adert,
        redirect:'/adert/list',
        //三级路由
        children:[
          {
            path:'list',
            name:'AdertList',
            component:AdertList
          },
          
          {
            path:'manger',
            name:'AdertManger',
            component:AdertManger
          }
         
          
        ]

      },
      //数据统计
      {
        path:'/data',
        name:'Data',
        component:Data
      }
    ]

  },
  {
    path:'/login',
    name:'login',
    component:()=>import('../views/login/index.vue')
  }
  
]

const router = new VueRouter({
  routes
})

export default router
